<?php

namespace App\Server\Wxapp;

class StoreQrcode
{
    private $uploadServer;

    public function __construct()
    {
        $this->uploadServer = new \App\Server\Upload\Index;
    }

    public function get($accessToken, $params)
    {
        $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" . $accessToken;
        $request = new \App\Server\Request\WxRequest;
        $binaryImg = $request->fetchApi($url, $params, 'POST', 'raw');
        $tempFileName = tempnam(sys_get_temp_dir(), 'UPLOAD'); 
        file_put_contents($tempFileName, $binaryImg);
        return $this->uploadServer->init('wxapp_qr_code', $tempFileName);
    }
}